#ifndef OHOS_VIDEO_SIZE_MEASURE_H_
#define OHOS_VIDEO_SIZE_MEASURE_H_

#include <cmath>
#include <stdexcept>
#include <utility>
#include "api/video/video_frame.h"
#include "api/video/video_scale_mode.h"

namespace webrtc {
class VideoSizeMeasure {
 public:
  void SetScaleType(webrtc::VideoScaleMode h_match_scale_type,
                    webrtc::VideoScaleMode h_mismatch_scale_type,
                    webrtc::VideoScaleMode v_match_scale_type,
                    webrtc::VideoScaleMode v_mismatch_scale_type);
  std::pair<int, int> Measure(int surface_width, int surface_height, int frame_width, int frame_height);

  static std::pair<int, int> GetDisplaySize(webrtc::VideoScaleMode scaling_type, float video_aspect_ratio, int max_display_width, int max_display_height);

 private:
  static float ConvertScaleTypeToVisibleFraction(webrtc::VideoScaleMode scaling_type);
  static std::pair<int, int> GetDisplaySize(float min_visible_fraction, float video_aspect_ratio, int max_display_width, int max_display_height);

 webrtc::VideoScaleMode scaling_type_match_orientation_h_ = webrtc::VideoScaleMode::kModeScaleToFill;
 webrtc::VideoScaleMode scaling_type_mismatch_orientation_h_ = webrtc::VideoScaleMode::kModeScaleToFill;
 webrtc::VideoScaleMode scaling_type_match_orientation_v_ = webrtc::VideoScaleMode::kModeScaleToFill;
 webrtc::VideoScaleMode scaling_type_mismatch_orientation_v_ = webrtc::VideoScaleMode::kModeScaleToFill;
};
}

#endif //OHOS_VIDEO_SIZE_MEASURE_H_
